import { RequestImpl } from "../Impl.interface";
import _axios from './axios';
import { AxiosRequestConfig, AxiosResponse } from "axios";

export class Axios implements RequestImpl {
  get<T = any, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R> {
    return _axios.post<T>(url, config) as Promise<R>;
  }
  post<T = any, R = AxiosResponse<T, any>, D = any>(url: string, data?: D, config?: AxiosRequestConfig<D>): Promise<R> {
    return _axios.post<T>(url, data, config) as Promise<R>;
  }
  delete<T = any, R = AxiosResponse<T, any>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R> {
    return _axios.delete<T>(url, config) as Promise<R>;
  }
  put<T = any, R = AxiosResponse<T, any>, D = any>(url: string, data?: D, config?: AxiosRequestConfig<D>): Promise<R> {
    return _axios.put<T>(url, data, config) as Promise<R>;
  }
}
